Class: Moonrope::StructureAttribute
- Inherits:
-
Object
- Object
- Moonrope::StructureAttribute
- Defined in:
- lib/moonrope/structure_attribute.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#description ⇒ Object
Returns the value of attribute description.
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#example ⇒ Object
Returns the value of attribute example.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#mutation ⇒ Object
Returns the value of attribute mutation.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source_attribute ⇒ Object
Returns the value of attribute source_attribute.
-
#structure ⇒ Object
Returns the value of attribute structure.
-
#structure_opts ⇒ Object
Returns the value of attribute structure_opts.
-
#value ⇒ Object
Returns the value of attribute value.
-
#value_type ⇒ Object
Returns the value of attribute value_type.
Instance Method Summary collapse
- #auto_mutate(value) ⇒ Object
-
#initialize(type, name) ⇒ StructureAttribute
constructor
A new instance of StructureAttribute.
- #mutate(value) ⇒ Object
- #name_with_groups ⇒ Object
Constructor Details
#initialize(type, name) ⇒ StructureAttribute
Returns a new instance of StructureAttribute.
17 18 19 20 21 22 |
# File 'lib/moonrope/structure_attribute.rb', line 17 def initialize(type, name) @type = type @name = name @groups = [] @conditions = [] end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
6 7 8 |
# File 'lib/moonrope/structure_attribute.rb', line 6 def conditions @conditions end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/moonrope/structure_attribute.rb', line 8 def description @description end |
#doc ⇒ Object
Returns the value of attribute doc.
14 15 16 |
# File 'lib/moonrope/structure_attribute.rb', line 14 def doc @doc end |
#example ⇒ Object
Returns the value of attribute example.
13 14 15 |
# File 'lib/moonrope/structure_attribute.rb', line 13 def example @example end |
#groups ⇒ Object
Returns the value of attribute groups.
5 6 7 |
# File 'lib/moonrope/structure_attribute.rb', line 5 def groups @groups end |
#mutation ⇒ Object
Returns the value of attribute mutation.
15 16 17 |
# File 'lib/moonrope/structure_attribute.rb', line 15 def mutation @mutation end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/moonrope/structure_attribute.rb', line 4 def name @name end |
#source_attribute ⇒ Object
Returns the value of attribute source_attribute.
7 8 9 |
# File 'lib/moonrope/structure_attribute.rb', line 7 def source_attribute @source_attribute end |
#structure ⇒ Object
Returns the value of attribute structure.
10 11 12 |
# File 'lib/moonrope/structure_attribute.rb', line 10 def structure @structure end |
#structure_opts ⇒ Object
Returns the value of attribute structure_opts.
11 12 13 |
# File 'lib/moonrope/structure_attribute.rb', line 11 def structure_opts @structure_opts end |
#value ⇒ Object
Returns the value of attribute value.
12 13 14 |
# File 'lib/moonrope/structure_attribute.rb', line 12 def value @value end |
#value_type ⇒ Object
Returns the value of attribute value_type.
9 10 11 |
# File 'lib/moonrope/structure_attribute.rb', line 9 def value_type @value_type end |
Instance Method Details
#auto_mutate(value) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/moonrope/structure_attribute.rb', line 40 def auto_mutate(value) case value_type when :timestamp value.is_a?(Time) ? value.to_s : value when :unix_timestamp value.nil? ? nil : value.to_i else value end end |
#mutate(value) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/moonrope/structure_attribute.rb', line 32 def mutate(value) if mutation value ? value.public_send(mutation) : nil else auto_mutate(value) end end |
#name_with_groups ⇒ Object
28 29 30 |
# File 'lib/moonrope/structure_attribute.rb', line 28 def name_with_groups ([groups] + [name]).flatten.compact.join('.') end |