Class: Fauxsql::AttributeWrapper
- Inherits:
-
Object
- Object
- Fauxsql::AttributeWrapper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/fauxsql/attribute_wrapper.rb
Direct Known Subclasses
Defined Under Namespace
Classes: MissingOptions
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #dirty! ⇒ Object
- #get_nested_record(vals) ⇒ Object
-
#initialize(attribute, record, name, options) ⇒ AttributeWrapper
constructor
A new instance of AttributeWrapper.
Constructor Details
#initialize(attribute, record, name, options) ⇒ AttributeWrapper
Returns a new instance of AttributeWrapper.
14 15 16 17 18 |
# File 'lib/fauxsql/attribute_wrapper.rb', line 14 def initialize(attribute, record, name, ) raise MissingOptions if .nil? @attribute, @record, @name, @options = attribute, record, name, @record.fauxsql_attributes[name] ||= attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
9 10 11 |
# File 'lib/fauxsql/attribute_wrapper.rb', line 9 def attribute @attribute end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/fauxsql/attribute_wrapper.rb', line 11 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/fauxsql/attribute_wrapper.rb', line 12 def @options end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
10 11 12 |
# File 'lib/fauxsql/attribute_wrapper.rb', line 10 def record @record end |
Instance Method Details
#dirty! ⇒ Object
27 28 29 |
# File 'lib/fauxsql/attribute_wrapper.rb', line 27 def dirty! Fauxsql.dirty!(record){ yield } end |
#get_nested_record(vals) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/fauxsql/attribute_wrapper.rb', line 20 def get_nested_record(vals) model = vals[:type].constantize raise MissingOptions.new(:nest, ) unless [:nest] raise InvalidNesting unless [:nest].include?(model) model.get(vals["#{model.name}_id".to_sym]) end |