Class: Rexport::DataField
- Inherits:
-
Object
- Object
- Rexport::DataField
- Includes:
- Comparable
- Defined in:
- lib/rexport/data_field.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sort by name.
-
#association_name ⇒ Object
Returns the first association name from a method chain string.
-
#initialize(name, options = {}) ⇒ DataField
constructor
Stores the name and method of the export data item.
Constructor Details
#initialize(name, options = {}) ⇒ DataField
Stores the name and method of the export data item
9 10 11 12 13 |
# File 'lib/rexport/data_field.rb', line 9 def initialize(name, = {}) @name = name.to_s @method = [:method].blank? ? self.name : [:method].to_s @type = [:type] end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
6 7 8 |
# File 'lib/rexport/data_field.rb', line 6 def method @method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rexport/data_field.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/rexport/data_field.rb', line 6 def type @type end |
Instance Method Details
#<=>(other) ⇒ Object
Sort by name
16 17 18 |
# File 'lib/rexport/data_field.rb', line 16 def <=>(other) name <=> other.name end |
#association_name ⇒ Object
Returns the first association name from a method chain string. If the string does not contain the dot operator a nil is returned.
Examples:
"assocation.method" # => "association"
"assocation_one.assocation_two.method" # => "assocation_one"
"method" # => nil
28 29 30 |
# File 'lib/rexport/data_field.rb', line 28 def association_name method[0..(first_dot_index - 1)] if first_dot_index.present? end |