Class: Femto::Model::ModelCreator
- Inherits:
-
Object
- Object
- Femto::Model::ModelCreator
- Defined in:
- lib/femto/model.rb
Instance Attribute Summary collapse
-
#class_opts ⇒ Object
Returns the value of attribute class_opts.
-
#custom_methods ⇒ Object
Returns the value of attribute custom_methods.
-
#defaults ⇒ Object
Returns the value of attribute defaults.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#storage_name ⇒ Object
Returns the value of attribute storage_name.
-
#types ⇒ Object
Returns the value of attribute types.
Instance Method Summary collapse
- #class_options(&block) ⇒ Object
- #field(name, options = {}) ⇒ Object
-
#initialize ⇒ ModelCreator
constructor
A new instance of ModelCreator.
- #set_method(name, &block) ⇒ Object
- #storage(name) ⇒ Object
Constructor Details
#initialize ⇒ ModelCreator
Returns a new instance of ModelCreator.
104 105 106 107 108 109 |
# File 'lib/femto/model.rb', line 104 def initialize @fields = [] @defaults = {} @types = {} @custom_methods = {} end |
Instance Attribute Details
#class_opts ⇒ Object
Returns the value of attribute class_opts.
100 101 102 |
# File 'lib/femto/model.rb', line 100 def class_opts @class_opts end |
#custom_methods ⇒ Object
Returns the value of attribute custom_methods.
101 102 103 |
# File 'lib/femto/model.rb', line 101 def custom_methods @custom_methods end |
#defaults ⇒ Object
Returns the value of attribute defaults.
98 99 100 |
# File 'lib/femto/model.rb', line 98 def defaults @defaults end |
#fields ⇒ Object
Returns the value of attribute fields.
97 98 99 |
# File 'lib/femto/model.rb', line 97 def fields @fields end |
#storage_name ⇒ Object
Returns the value of attribute storage_name.
102 103 104 |
# File 'lib/femto/model.rb', line 102 def storage_name @storage_name end |
#types ⇒ Object
Returns the value of attribute types.
99 100 101 |
# File 'lib/femto/model.rb', line 99 def types @types end |
Instance Method Details
#class_options(&block) ⇒ Object
119 120 121 |
# File 'lib/femto/model.rb', line 119 def (&block) @class_opts = block end |
#field(name, options = {}) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/femto/model.rb', line 111 def field(name, ={}) return unless name fields << name if [:default] defaults[name] end end |
#set_method(name, &block) ⇒ Object
123 124 125 |
# File 'lib/femto/model.rb', line 123 def set_method(name, &block) custom_methods[name] = block end |
#storage(name) ⇒ Object
127 128 129 |
# File 'lib/femto/model.rb', line 127 def storage(name) @storage_name = name end |