Class: Ken::Attribute
- Inherits:
-
Object
- Object
- Ken::Attribute
- Includes:
- Extlib::Assertions
- Defined in:
- lib/ken/attribute.rb
Instance Attribute Summary collapse
-
#property ⇒ Object
readonly
Returns the value of attribute property.
Class Method Summary collapse
-
.create(data, property) ⇒ Object
factory method for creating an attribute instance.
Instance Method Summary collapse
-
#initialize(data, property) ⇒ Attribute
constructor
initializes a resource by json result.
- #inspect ⇒ Object
-
#object_type? ⇒ Boolean
object type properties always link to resources.
- #to_s ⇒ Object
-
#unique? ⇒ Boolean
unique properties can have at least one value.
-
#value_type? ⇒ Boolean
returns true if the property is a value type value type properties refer to simple values like /type/text.
-
#values ⇒ Object
returns a collection of values in case of a unique property the array holds just one value.
Constructor Details
#initialize(data, property) ⇒ Attribute
initializes a resource by json result
8 9 10 11 12 |
# File 'lib/ken/attribute.rb', line 8 def initialize(data, property) assert_kind_of 'data', data, Array assert_kind_of 'property', property, Ken::Property @data, @property = data, property end |
Instance Attribute Details
#property ⇒ Object (readonly)
Returns the value of attribute property.
5 6 7 |
# File 'lib/ken/attribute.rb', line 5 def property @property end |
Class Method Details
.create(data, property) ⇒ Object
factory method for creating an attribute instance
16 17 18 |
# File 'lib/ken/attribute.rb', line 16 def self.create(data, property) Ken::Attribute.new(data, property) end |
Instance Method Details
#inspect ⇒ Object
26 27 28 |
# File 'lib/ken/attribute.rb', line 26 def inspect result = "#<Attribute property=\"#{property.id || "nil"}\">" end |
#object_type? ⇒ Boolean
object type properties always link to resources
45 46 47 |
# File 'lib/ken/attribute.rb', line 45 def object_type? @property.object_type? end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/ken/attribute.rb', line 21 def to_s subject.to_s end |
#unique? ⇒ Boolean
unique properties can have at least one value
39 40 41 |
# File 'lib/ken/attribute.rb', line 39 def unique? @property.unique? end |
#value_type? ⇒ Boolean
returns true if the property is a value type value type properties refer to simple values like /type/text
52 53 54 |
# File 'lib/ken/attribute.rb', line 52 def value_type? @property.value_type? end |
#values ⇒ Object
returns a collection of values in case of a unique property the array holds just one value
33 34 35 |
# File 'lib/ken/attribute.rb', line 33 def values subject end |