Class: ActiveRecord::TypedStore::DSL
- Inherits:
-
Object
- Object
- ActiveRecord::TypedStore::DSL
- Defined in:
- lib/active_record/typed_store/dsl.rb
Constant Summary collapse
- NO_DEFAULT_GIVEN =
Object.new
Instance Attribute Summary collapse
-
#coder ⇒ Object
readonly
Returns the value of attribute coder.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #accessors ⇒ Object
- #default_coder(attribute_name) ⇒ Object
-
#initialize(attribute_name, options) {|_self| ... } ⇒ DSL
constructor
A new instance of DSL.
Constructor Details
#initialize(attribute_name, options) {|_self| ... } ⇒ DSL
Returns a new instance of DSL.
9 10 11 12 13 14 15 |
# File 'lib/active_record/typed_store/dsl.rb', line 9 def initialize(attribute_name, ) @coder = .fetch(:coder) { default_coder(attribute_name) } @accessors = [:accessors] @accessors = [] if [:accessors] == false @fields = {} yield self end |
Instance Attribute Details
#coder ⇒ Object (readonly)
Returns the value of attribute coder.
7 8 9 |
# File 'lib/active_record/typed_store/dsl.rb', line 7 def coder @coder end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
7 8 9 |
# File 'lib/active_record/typed_store/dsl.rb', line 7 def fields @fields end |
Instance Method Details
#accessors ⇒ Object
27 28 29 |
# File 'lib/active_record/typed_store/dsl.rb', line 27 def accessors @accessors || @fields.values.select(&:accessor).map(&:name) end |
#default_coder(attribute_name) ⇒ Object
18 19 20 |
# File 'lib/active_record/typed_store/dsl.rb', line 18 def default_coder(attribute_name) ActiveRecord::Coders::YAMLColumn.new end |