Module: Mobility::Plugins::Attributes::ClassMethods

Defined in:
lib/mobility/plugins/attributes.rb

Instance Method Summary collapse

Instance Method Details

#inherited(klass) ⇒ Object



54
55
56
57
58
# File 'lib/mobility/plugins/attributes.rb', line 54

def inherited(klass)
  super
  attrs = mobility_attributes.freeze # ensure attributes are not modified after being inherited
  klass.class_eval { @mobility_attributes = attrs.dup }
end

#mobility_attribute?(name) ⇒ Boolean

Return true if attribute name is translated on this model.

Parameters:

  • Attribute (String, Symbol)

    name

Returns:

  • (Boolean)


44
45
46
# File 'lib/mobility/plugins/attributes.rb', line 44

def mobility_attribute?(name)
  mobility_attributes.include?(name.to_s)
end

#mobility_attributesArray<String>

Return translated attribute names on this model.

Returns:

  • (Array<String>)

    Attribute names



50
51
52
# File 'lib/mobility/plugins/attributes.rb', line 50

def mobility_attributes
  @mobility_attributes ||= []
end