Module: YARD::Mongoid::Helpers
- Included in:
- FieldHandler, Legacy::FieldHandler
- Defined in:
- lib/yard/mongoid/helpers.rb
Instance Method Summary collapse
-
#register_field_change(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new
name
_change method innamespace
with an instance or classscope
. -
#register_field_changed(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new
name
_changed? method innamespace
with an instance or classscope
. -
#register_field_getter(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new
name
method innamespace
with an instance or classscope
. -
#register_field_presence(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new
name
? method innamespace
with an instance or classscope
. -
#register_field_reset(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new reset_
name
! method innamespace
with an instance or classscope
. -
#register_field_setter(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new
name
= method innamespace
with an instance or classscope
. -
#register_field_was(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new
name
_was method innamespace
with an instance or classscope
. - #register_new_method_object(namespace, name, scope = :instance, &block) ⇒ Object
Instance Method Details
#register_field_change(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new name
_change method in namespace
with an instance or class scope
55 56 57 58 59 60 61 |
# File 'lib/yard/mongoid/helpers.rb', line 55 def register_field_change(namespace, name, scope = :instance) register_new_method_object(namespace, "#{name}_change", scope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}_change" end end |
#register_field_changed(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new name
_changed? method in namespace
with an instance or class scope
68 69 70 71 72 73 74 |
# File 'lib/yard/mongoid/helpers.rb', line 68 def register_field_changed(namespace, name, scope = :instance) register_new_method_object(namespace, "#{name}_changed?", scope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}_changed?" end end |
#register_field_getter(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new name
method in namespace
with an instance or class scope
13 14 15 16 17 18 19 20 |
# File 'lib/yard/mongoid/helpers.rb', line 13 def register_field_getter(namespace, name, scope = :instance) register_new_method_object(namespace, name, scope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}" o.docstring = "Returns the value of attribute #{name}" end end |
#register_field_presence(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new name
? method in namespace
with an instance or class scope
42 43 44 45 46 47 48 |
# File 'lib/yard/mongoid/helpers.rb', line 42 def register_field_presence(namespace, name, scope = :instance) register_new_method_object(namespace, "#{name}?", scope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}?" end end |
#register_field_reset(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new reset_name
! method in namespace
with an instance or class scope
94 95 96 97 98 99 100 |
# File 'lib/yard/mongoid/helpers.rb', line 94 def register_field_reset(namespace, name, scope = :instance) register_new_method_object(namespace, "reset_#{name}!", scope) do |o| o.visibility = :public o.source = statement.source o.signature = "def reset_#{name}!" end end |
#register_field_setter(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new name
= method in namespace
with an instance or class scope
27 28 29 30 31 32 33 34 35 |
# File 'lib/yard/mongoid/helpers.rb', line 27 def register_field_setter(namespace, name, scope = :instance) register_new_method_object(namespace, "#{name}=", scope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}=(value)" o.parameters = [['value', nil]] o.docstring = "Sets the attribute #{name}\n@param value the value to set the attribute #{name} to." end end |
#register_field_was(namespace, name, scope = :instance) ⇒ Object
Creates and registers a new name
_was method in namespace
with an instance or class scope
81 82 83 84 85 86 87 |
# File 'lib/yard/mongoid/helpers.rb', line 81 def register_field_was(namespace, name, scope = :instance) register_new_method_object(namespace, "#{name}_was", scope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}_was" end end |
#register_new_method_object(namespace, name, scope = :instance, &block) ⇒ Object
4 5 6 |
# File 'lib/yard/mongoid/helpers.rb', line 4 def register_new_method_object(namespace, name, scope = :instance, &block) register self.class.const_get(:MethodObject).new(namespace, name, scope, &block) end |