Module: Creatable
- Defined in:
- lib/creatable.rb,
lib/creatable/version.rb,
lib/creatable/instance_methods.rb
Overview
Main module you include in your class
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- VERSION =
VERSION
'2.1.0'.freeze
Class Method Summary collapse
-
.included(object) ⇒ Void
Override to load the ClassMethods.
Instance Method Summary collapse
-
#attribute_names ⇒ Array
Returns the names of the attributes.
-
#attributes ⇒ Hash
Returns the hash of built attributes.
-
#to_parameters ⇒ Hash
Returns the settings of all attributes.
Class Method Details
.included(object) ⇒ Void
Override to load the ClassMethods
9 10 11 |
# File 'lib/creatable.rb', line 9 def self.included(object) object.extend InstanceMethods end |
Instance Method Details
#attribute_names ⇒ Array
Returns the names of the attributes.
21 22 23 |
# File 'lib/creatable.rb', line 21 def attribute_names self.class.attributes.map { |a| a[:name] } end |
#attributes ⇒ Hash
Returns the hash of built attributes
15 16 17 |
# File 'lib/creatable.rb', line 15 def attributes self.class.attributes end |
#to_parameters ⇒ Hash
Returns the settings of all attributes.
27 28 29 30 31 32 33 |
# File 'lib/creatable.rb', line 27 def to_parameters h = {} attribute_names.each do |name| h.store name, instance_variable_get("@#{name}") end h end |