Class: Cassandra::Mapper::Utility::Config::DSL
- Inherits:
-
Object
- Object
- Cassandra::Mapper::Utility::Config::DSL
- Defined in:
- lib/cassandra/mapper/utility/config.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #after_insert(&block) ⇒ Object
- #after_remove(&block) ⇒ Object
- #before_insert(&block) ⇒ Object
- #before_remove(&block) ⇒ Object
-
#initialize(&block) ⇒ DSL
constructor
A new instance of DSL.
- #key(*fields) ⇒ Object
- #subkey(*fields) ⇒ Object
- #type(field, type) ⇒ Object
Constructor Details
#initialize(&block) ⇒ DSL
Returns a new instance of DSL.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cassandra/mapper/utility/config.rb', line 16 def initialize(&block) = { types: {}, before_insert: [], after_insert: [], after_remove: [], before_remove: [] } instance_eval &block end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/cassandra/mapper/utility/config.rb', line 14 def end |
Instance Method Details
#after_insert(&block) ⇒ Object
47 48 49 |
# File 'lib/cassandra/mapper/utility/config.rb', line 47 def after_insert(&block) [:after_insert].push block end |
#after_remove(&block) ⇒ Object
51 52 53 |
# File 'lib/cassandra/mapper/utility/config.rb', line 51 def after_remove(&block) [:after_remove].push block end |
#before_insert(&block) ⇒ Object
39 40 41 |
# File 'lib/cassandra/mapper/utility/config.rb', line 39 def before_insert(&block) [:before_insert].push block end |
#before_remove(&block) ⇒ Object
43 44 45 |
# File 'lib/cassandra/mapper/utility/config.rb', line 43 def before_remove(&block) [:before_remove].push block end |
#key(*fields) ⇒ Object
27 28 29 |
# File 'lib/cassandra/mapper/utility/config.rb', line 27 def key(*fields) [:key] = fields end |
#subkey(*fields) ⇒ Object
31 32 33 |
# File 'lib/cassandra/mapper/utility/config.rb', line 31 def subkey(*fields) [:subkey] = fields end |
#type(field, type) ⇒ Object
35 36 37 |
# File 'lib/cassandra/mapper/utility/config.rb', line 35 def type(field, type) [:types][field] = type end |