Class: DataPackage::Schema
- Inherits:
-
Base
- Object
- Base
- DataPackage::Schema
show all
- Defined in:
- lib/data_package/schema.rb
Instance Method Summary
collapse
#to_hash, #to_json
#attr_missing?, #attr_present?, #attr_required?, #attributes, included, #missing_attributes, #optional_attributes, #required_attributes, #write_attribute, #write_attributes
Constructor Details
#initialize(attrs = {}) ⇒ Schema
Returns a new instance of Schema.
11
12
13
14
15
|
# File 'lib/data_package/schema.rb', line 11
def initialize(attrs = {})
@fields ||= []
super(attrs)
end
|
Instance Method Details
#fields=(json) ⇒ Object
17
18
19
|
# File 'lib/data_package/schema.rb', line 17
def fields=(json)
@fields = json.collect{|f| Field.new(f)}
end
|
#has_primary_key? ⇒ Boolean
33
34
35
|
# File 'lib/data_package/schema.rb', line 33
def has_primary_key?
primary_key.length > 0
end
|
#primary_key ⇒ Object
29
30
31
|
# File 'lib/data_package/schema.rb', line 29
def primary_key
@primary_key || []
end
|
#primary_key=(json) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/data_package/schema.rb', line 21
def primary_key=(json)
if json.is_a?(Array)
@primary_key = json
else
@primary_key = [json]
end
end
|