Class: Promiscuous::DSL::Definition
- Inherits:
-
Object
- Object
- Promiscuous::DSL::Definition
- Defined in:
- lib/promiscuous/dsl.rb
Instance Method Summary collapse
- #attributes(*fields) ⇒ Object (also: #attribute)
-
#initialize(mode, model, options) ⇒ Definition
constructor
A new instance of Definition.
- #track_dependencies_of(field) ⇒ Object
Constructor Details
#initialize(mode, model, options) ⇒ Definition
Returns a new instance of Definition.
15 16 17 18 19 20 21 22 23 |
# File 'lib/promiscuous/dsl.rb', line 15 def initialize(mode, model, ) @mode = mode @model = model @options = @model_class = @model.to_s.singularize.classify.constantize promiscuous_include = mode == :publish ? Promiscuous::Publisher : Promiscuous::Subscriber @model_class.class_eval { include promiscuous_include } end |
Instance Method Details
#attributes(*fields) ⇒ Object Also known as: attribute
25 26 27 28 |
# File 'lib/promiscuous/dsl.rb', line 25 def attributes(*fields) = fields. @model_class.__send__(@mode, *fields, @options.merge()) end |
#track_dependencies_of(field) ⇒ Object
30 31 32 |
# File 'lib/promiscuous/dsl.rb', line 30 def track_dependencies_of(field) @model_class.track_dependencies_of(field) end |