Class: Para::ModelFieldParsers::Base
- Inherits:
-
Object
- Object
- Para::ModelFieldParsers::Base
- Defined in:
- lib/para/model_field_parsers/base.rb
Direct Known Subclasses
ClosureTree, Devise, Enums, FriendlyId, Globalize, Orderable, Paperclip, Relations, Store, WysiwygEditor
Instance Attribute Summary collapse
-
#fields_hash ⇒ Object
readonly
Returns the value of attribute fields_hash.
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
- #applicable? ⇒ Boolean
- #find_attributes_for_mapping(type) ⇒ Object
-
#initialize(model, fields_hash, mappings) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(model, fields_hash, mappings) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 |
# File 'lib/para/model_field_parsers/base.rb', line 10 def initialize(model, fields_hash, mappings) @model = model @fields_hash = fields_hash @mappings = mappings end |
Instance Attribute Details
#fields_hash ⇒ Object (readonly)
Returns the value of attribute fields_hash.
8 9 10 |
# File 'lib/para/model_field_parsers/base.rb', line 8 def fields_hash @fields_hash end |
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings.
8 9 10 |
# File 'lib/para/model_field_parsers/base.rb', line 8 def mappings @mappings end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/para/model_field_parsers/base.rb', line 8 def model @model end |
Class Method Details
.register(key, parser) ⇒ Object
4 5 6 |
# File 'lib/para/model_field_parsers/base.rb', line 4 def self.register(key, parser) ModelFieldParsers.registered_parsers[key] = parser end |
Instance Method Details
#applicable? ⇒ Boolean
16 17 18 |
# File 'lib/para/model_field_parsers/base.rb', line 16 def applicable? true end |
#find_attributes_for_mapping(type) ⇒ Object
20 21 22 |
# File 'lib/para/model_field_parsers/base.rb', line 20 def find_attributes_for_mapping(type) mappings.select { |k, v| v == type.to_s }.keys.map(&:to_sym) end |