Class: CardDB::DatasetSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/carddb/collection.rb

Overview

Wrapper for DatasetSchema

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ DatasetSchema

Returns a new instance of DatasetSchema.



619
620
621
# File 'lib/carddb/collection.rb', line 619

def initialize(data)
  @data = data || {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



617
618
619
# File 'lib/carddb/collection.rb', line 617

def data
  @data
end

Instance Method Details

#field(key) ⇒ Object

Find a field by key



644
645
646
# File 'lib/carddb/collection.rb', line 644

def field(key)
  fields.find { |f| f.key == key.to_s }
end

#field_keysObject



627
628
629
# File 'lib/carddb/collection.rb', line 627

def field_keys
  fields.map(&:key)
end

#fieldsObject



623
624
625
# File 'lib/carddb/collection.rb', line 623

def fields
  @fields ||= (data['fields'] || []).map { |f| FieldInfo.new(f) }
end

#filterable_fieldsObject



631
632
633
# File 'lib/carddb/collection.rb', line 631

def filterable_fields
  data['filterableFields'] || []
end


639
640
641
# File 'lib/carddb/collection.rb', line 639

def link_fields
  @link_fields ||= (data['linkFields'] || []).map { |f| LinkFieldInfo.new(f) }
end

#searchable_fieldsObject



635
636
637
# File 'lib/carddb/collection.rb', line 635

def searchable_fields
  data['searchableFields'] || []
end