Class: Moon::DataModel::Metal
- Inherits:
-
Object
- Object
- Moon::DataModel::Metal
- Includes:
- Fields, Serializable
- Defined in:
- lib/data_model/metal.rb
Overview
Metal is a generic implementation of Moon::DataModel::Model
Direct Known Subclasses
Constant Summary collapse
- @@dmid =
0
Instance Attribute Summary collapse
-
#dmid ⇒ Object
readonly
Returns the value of attribute dmid.
Instance Method Summary collapse
- #initialize(options = {}) {|_self| ... } ⇒ Metal constructor
-
#post_initialize ⇒ void
Final initialization method, use this as your own initialize method.
-
#pre_initialize ⇒ void
Pre initialization method, use this as a way to setup the model before its fields are initialized.
-
#to_h ⇒ Hash<Symbol, Object>
Converts the Model to a Hash, all fields will be converted to Hashes via #to_h.
Methods included from Fields
adjust_field_options, included
Methods included from Fields::InstanceMethods
#[], #[]=, #assoc, #each_field, #each_field_name, #each_field_with_value, #each_pair, #each_value, #field_get, #field_set, #field_set!, #fields=, #fields_hash, #initialize_fields, #invalid?, #post_initialize_fields, #pre_initialize_fields, #reset_field, #reset_fields, #update_fields, #update_fields!, #valid?, #validate, #validate_fields?
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Metal
25 26 27 28 29 30 31 |
# File 'lib/data_model/metal.rb', line 25 def initialize( = {}) @dmid = @@dmid += 1 pre_initialize initialize_fields() yield self if block_given? post_initialize end |
Instance Attribute Details
#dmid ⇒ Object (readonly)
Returns the value of attribute dmid
19 20 21 |
# File 'lib/data_model/metal.rb', line 19 def dmid @dmid end |
Instance Method Details
#post_initialize ⇒ void
This method returns an undefined value.
Final initialization method, use this as your own initialize method. Called after the fields have been initialized at the very end. if you need to change the model before it ever reaches the user use Fields::InstanceMethods#post_initialize_fields instead.
46 47 |
# File 'lib/data_model/metal.rb', line 46 def post_initialize end |
#pre_initialize ⇒ void
This method returns an undefined value.
Pre initialization method, use this as a way to setup the model before its fields are initialized.
37 38 |
# File 'lib/data_model/metal.rb', line 37 def pre_initialize end |
#to_h ⇒ Hash<Symbol, Object>
Converts the Model to a Hash, all fields will be converted to Hashes via #to_h
53 54 55 |
# File 'lib/data_model/metal.rb', line 53 def to_h FieldsToHash.call(self) end |