Class: Stratagem::ApplicationExtensions::Models::Adapters::Common::Metadata
- Inherits:
-
Object
- Object
- Stratagem::ApplicationExtensions::Models::Adapters::Common::Metadata
- Defined in:
- lib/stratagem/framework_extensions/models/adapters/common/metadata.rb
Overview
prefix method names with to avoid collision
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #attribute_names ⇒ Object
-
#ignore_attributes ⇒ Object
junk attributes.
-
#initialize(model) ⇒ Metadata
constructor
A new instance of Metadata.
Constructor Details
#initialize(model) ⇒ Metadata
Returns a new instance of Metadata.
8 9 10 11 |
# File 'lib/stratagem/framework_extensions/models/adapters/common/metadata.rb', line 8 def initialize(model) @model = model @instance = @model.new unless (@model == ActiveRecord::Base) end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
6 7 8 |
# File 'lib/stratagem/framework_extensions/models/adapters/common/metadata.rb', line 6 def instance @instance end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/stratagem/framework_extensions/models/adapters/common/metadata.rb', line 6 def model @model end |
Instance Method Details
#attribute_names ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/stratagem/framework_extensions/models/adapters/common/metadata.rb', line 13 def attribute_names @attribute_names ||= begin names = model.new.methods.select {|m| s = m.to_s if (s.to_s =~ /=$/) name = s.gsub(/=$/, '') name.singularize == name else false end }.map {|m| m.to_s.gsub(/=$/, '').to_sym } names - (model.stratagem.internal_attributes + model.stratagem.ignore_attributes + model.stratagem.relation_names) end end |
#ignore_attributes ⇒ Object
junk attributes
31 32 33 |
# File 'lib/stratagem/framework_extensions/models/adapters/common/metadata.rb', line 31 def ignore_attributes @ignore_attributes ||= ["!", "[]", "===", "==", "=", "taguri"].map {|a| a.to_sym } end |