Module: Calculi::Attributes::ClassMethods
- Defined in:
- lib/calculi/attributes.rb
Instance Method Summary collapse
- #calculi_attr(name, type, options = {}, &custom_setter) ⇒ Object
- #calculi_boolean(name, options = {}) ⇒ Object (also: #calculi_bool)
- #calculi_computed(name, &computer_block) ⇒ Object
- #calculi_duration(name, options = {}) ⇒ Object
- #calculi_integer(name, options = {}) ⇒ Object (also: #calculi_int)
- #calculi_procable(name, options = {}) ⇒ Object
- #calculi_string(name, options = {}) ⇒ Object
Instance Method Details
#calculi_attr(name, type, options = {}, &custom_setter) ⇒ Object
28 29 30 31 32 |
# File 'lib/calculi/attributes.rb', line 28 def calculi_attr(name, type, = {}, &custom_setter) type = Calculi::Attribute.lookup(type) include type.new(name, , &custom_setter) end |
#calculi_boolean(name, options = {}) ⇒ Object Also known as: calculi_bool
34 35 36 37 38 |
# File 'lib/calculi/attributes.rb', line 34 def calculi_boolean(name, = {}) = { default: true } if == true calculi_attr name, :boolean, end |
#calculi_computed(name, &computer_block) ⇒ Object
42 43 44 45 46 |
# File 'lib/calculi/attributes.rb', line 42 def calculi_computed(name, &computer_block) define_method(name) do instance_variable_compute(name, &computer_block) end end |
#calculi_duration(name, options = {}) ⇒ Object
48 49 50 |
# File 'lib/calculi/attributes.rb', line 48 def calculi_duration(name, = {}) calculi_attr name, :duration, end |
#calculi_integer(name, options = {}) ⇒ Object Also known as: calculi_int
52 53 54 |
# File 'lib/calculi/attributes.rb', line 52 def calculi_integer(name, = {}) calculi_attr name, :integer, end |
#calculi_procable(name, options = {}) ⇒ Object
58 59 60 |
# File 'lib/calculi/attributes.rb', line 58 def calculi_procable(name, = {}) calculi_attr name, :procable, end |
#calculi_string(name, options = {}) ⇒ Object
62 63 64 |
# File 'lib/calculi/attributes.rb', line 62 def calculi_string(name, = {}) calculi_attr name, :string, end |