class ShafClient::Alps::Descriptor

Attributes

doc[R]
ext[R]
extensions[R]
href[R]
id[R]
name[R]
type[R]

Public Class Methods

new(id:, **kwargs) click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 8
def initialize(id:, **kwargs)
  @id   = id.to_sym
  @href = kwargs[:href]
  @name = kwargs[:name]
  @type = kwargs[:type]
  @doc  = kwargs[:doc]
  @ext  = parse_extentions(kwargs[:ext])
end

Public Instance Methods

extension(id) click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 46
def extension(id)
  extensions.find { |ext| ext.id == id.to_sym }
end
idempotent?() click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 38
def idempotent?
  type == 'idempotent'
end
safe?() click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 34
def safe?
  type == 'safe'
end
semantic?() click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 30
def semantic?
  type == 'semantic'
end
to_h() click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 19
def to_h
  {
    id: id,
    href: href,
    name: name,
    type: type,
    doc: doc,
    ext: extensions.map(&:to_h),
  }
end
unsafe?() click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 42
def unsafe?
  type == 'unsafe'
end

Private Instance Methods

parse_extentions(extensions) click to toggle source
# File lib/shaf_client/alps/descriptor.rb, line 52
def parse_extentions(extensions)
  extensions ||= []
  extensions = [extensions] unless extensions.is_a? Array
  extensions.map { |ext| Extension.new(**ext.transform_keys(&:to_sym)) }
end