Module: Embedson::Model
- Defined in:
- lib/embedson/model.rb,
lib/embedson/model/embeds_builder.rb,
lib/embedson/model/method_builder.rb,
lib/embedson/model/embedded_builder.rb
Overview
Defined Under Namespace
Classes: EmbeddedBuilder, EmbedsBuilder, MethodBuilder
Class Method Summary collapse
Instance Method Summary collapse
-
#embedded_in(name, options = {}) ⇒ Object
Public: Creates methods to manage parent class.
-
#embeds_one(name, options = {}) ⇒ Object
Public: Creates methods to manage embedded class.
Class Method Details
.extended(mod) ⇒ Object
53 54 55 |
# File 'lib/embedson/model.rb', line 53 def self.extended(mod) attr_reader :embedson_relations end |
Instance Method Details
#embedded_in(name, options = {}) ⇒ Object
Public: Creates methods to manage parent class.
name - Name of relation where parent object will be stored. options - The hash options used to define custom class name and field name
in parent class (default: {}):
:class_name - Name of class where current object will be embedded.
:inverse_of - Name of field where parent class will keep current object.
Examples
:parent, class_name: Test, inverse_of: :virt
:parent
Returns nothing
47 48 49 50 51 |
# File 'lib/embedson/model.rb', line 47 def (name, = {}) @embedson_relations ||= [] @embedson_relations << name MethodBuilder.new(self, name, ). end |
#embeds_one(name, options = {}) ⇒ Object
Public: Creates methods to manage embedded class.
name - Name of of relation. options - The Hash options used to define custom column name, class name
and field name in embedded class (default: {}):
:class_name - Name of class which will be ebedded.
:column_name - Name of column where Hash representation will be stored.
:inverse_of - Name of field where related class will store current object.
:hash_method - Method name which returns hash representation os saved object. Default :to_h
Examples
:virt, class_name: Virt, column_name: :data, inverse_of: :parent
:virt
Returns nothing
28 29 30 |
# File 'lib/embedson/model.rb', line 28 def (name, = {}) MethodBuilder.new(self, name, ). end |