Class: DataPackage::Schema

Inherits:
Base
  • Object
show all
Defined in:
lib/data_package/schema.rb

Instance Method Summary collapse

Methods included from AttrHelper::Serialization

#to_hash, #to_json

Methods included from AttrHelper::Base

#attr_missing?, #attr_present?, #attr_required?, #attributes, included, #missing_attributes, #optional_attributes, #required_attributes, #write_attribute, #write_attributes

Constructor Details

#initialize(attrs = {}) ⇒ Schema



10
11
12
13
14
# File 'lib/data_package/schema.rb', line 10

def initialize(attrs = {})
  @fields ||= []
  
  super(attrs)
end

Instance Method Details

#fields=(json) ⇒ Object



16
17
18
# File 'lib/data_package/schema.rb', line 16

def fields=(json)
  @fields = json.collect{|f| Field.new(f)}
end

#primary_key=(json) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/data_package/schema.rb', line 20

def primary_key=(json)
  if json.is_a?(Array)
    @primary_key = json
  else
    @primary_key = [json]
  end
end