Class: ListableCollections::Builder
- Inherits:
-
Object
- Object
- ListableCollections::Builder
- Defined in:
- lib/listable_collections/builder.rb
Instance Attribute Summary collapse
-
#concern ⇒ Object
readonly
Returns the value of attribute concern.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #define(attribute, options) ⇒ Object
-
#initialize(model) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(model) ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 |
# File 'lib/listable_collections/builder.rb', line 6 def initialize(model) @model = model @concern = Module.new end |
Instance Attribute Details
#concern ⇒ Object (readonly)
Returns the value of attribute concern.
4 5 6 |
# File 'lib/listable_collections/builder.rb', line 4 def concern @concern end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/listable_collections/builder.rb', line 4 def model @model end |
Instance Method Details
#define(attribute, options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/listable_collections/builder.rb', line 11 def define(attribute, ) plural = ([:as] || attribute).to_s singular = plural.singularize name = "#{singular}_list" variable = "@#{name}" was = "#{name}_was" model.define_attribute_method name define_list_writer name, variable, attribute, define_list_reader name, variable, attribute, define_added_to_list plural, name, was define_removed_from_list plural, name, was model.include concern end |