Class: ElasticRecord::SearchesMany::Builder
- Inherits:
-
Object
- Object
- ElasticRecord::SearchesMany::Builder
- Defined in:
- lib/elastic_record/searches_many/builder.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
- #define_reader ⇒ Object
- #define_writer ⇒ Object
-
#initialize(model, name, options) ⇒ Builder
constructor
A new instance of Builder.
- #mixin ⇒ Object
Constructor Details
#initialize(model, name, options) ⇒ Builder
Returns a new instance of Builder.
9 10 11 |
# File 'lib/elastic_record/searches_many/builder.rb', line 9 def initialize(model, name, ) @model, @name, @options = model, name, end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
8 9 10 |
# File 'lib/elastic_record/searches_many/builder.rb', line 8 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/elastic_record/searches_many/builder.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/elastic_record/searches_many/builder.rb', line 8 def @options end |
Class Method Details
.build(model, name, options) ⇒ Object
4 5 6 |
# File 'lib/elastic_record/searches_many/builder.rb', line 4 def self.build(model, name, ) new(model, name, ).build end |
Instance Method Details
#build ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/elastic_record/searches_many/builder.rb', line 13 def build define_writer define_reader reflection = ElasticRecord::SearchesMany::Reflection.new(model, name, ) model.searches_many_reflections = model.searches_many_reflections.merge(name => reflection) model.add_autosave_callbacks(reflection) # if options[:autosave] end |
#define_reader ⇒ Object
34 35 36 37 38 39 |
# File 'lib/elastic_record/searches_many/builder.rb', line 34 def define_reader name = self.name mixin.redefine_method(name) do searches_many_association(name).reader end end |
#define_writer ⇒ Object
27 28 29 30 31 32 |
# File 'lib/elastic_record/searches_many/builder.rb', line 27 def define_writer name = self.name mixin.redefine_method("#{name}=") do |records| searches_many_association(name).writer(records) end end |
#mixin ⇒ Object
23 24 25 |
# File 'lib/elastic_record/searches_many/builder.rb', line 23 def mixin model.generated_searches_many_methods end |