class Rexport::DataField
Attributes
method[R]
name[R]
type[R]
Public Class Methods
new(name, options = {})
click to toggle source
Stores the name and method of the export data item
# File lib/rexport/data_field.rb, line 9 def initialize(name, options = {}) @name = name.to_s @method = options[:method].blank? ? self.name : options[:method].to_s @type = options[:type] end
Public Instance Methods
<=>(other)
click to toggle source
Sort by name
# File lib/rexport/data_field.rb, line 16 def <=>(other) name <=> other.name end
association_name()
click to toggle source
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
# File lib/rexport/data_field.rb, line 28 def association_name method[0..(first_dot_index - 1)] if first_dot_index.present? end
Private Instance Methods
first_dot_index()
click to toggle source
# File lib/rexport/data_field.rb, line 34 def first_dot_index @first_dot_index ||= method.index(".") end