Class: MongoidSilo::GrainBelt
- Inherits:
-
Object
- Object
- MongoidSilo::GrainBelt
- Defined in:
- lib/mongoid_silo/grain_belt.rb
Class Attribute Summary collapse
-
.versioned_generators_store ⇒ Object
Returns the value of attribute versioned_generators_store.
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(object) ⇒ GrainBelt
constructor
A new instance of GrainBelt.
- #method_missing(meth, *args) ⇒ Object
Constructor Details
#initialize(object) ⇒ GrainBelt
Returns a new instance of GrainBelt.
26 27 28 |
# File 'lib/mongoid_silo/grain_belt.rb', line 26 def initialize(object) @object = object end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
30 31 32 |
# File 'lib/mongoid_silo/grain_belt.rb', line 30 def method_missing(meth, *args) object.send(meth) end |
Class Attribute Details
.versioned_generators_store ⇒ Object
Returns the value of attribute versioned_generators_store.
6 7 8 |
# File 'lib/mongoid_silo/grain_belt.rb', line 6 def versioned_generators_store @versioned_generators_store end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
3 4 5 |
# File 'lib/mongoid_silo/grain_belt.rb', line 3 def object @object end |
Class Method Details
.version(*args, &block) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/mongoid_silo/grain_belt.rb', line 18 def version(*args, &block) @versioned_generators_store ||= {} args.each do |version| @versioned_generators_store[version] = block end end |
.versioned_generators ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/mongoid_silo/grain_belt.rb', line 8 def versioned_generators @versioned_generators_store ||= {} if self == GrainBelt @versioned_generators_store else superclass.versioned_generators.merge(@versioned_generators_store) end end |
Instance Method Details
#generate ⇒ Object
34 35 36 37 38 |
# File 'lib/mongoid_silo/grain_belt.rb', line 34 def generate object.attribute_names.each_with_object({}) do |attribute, out| out[attribute] = object.send(attribute) unless ["_type", "_id"].include?(attribute) end end |