Module: Composable::Core::AttributeDSL
- Extended by:
- ActiveSupport::Concern
- Includes:
- InheritableAttributes
- Defined in:
- lib/composable/core/attribute_dsl.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#attributes ⇒ Object
30 31 32 |
# File 'lib/composable/core/attribute_dsl.rb', line 30 def attributes self.class.attributes end |
#initialize(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/composable/core/attribute_dsl.rb', line 14 def initialize( = {}) unless .respond_to?(:has_key?) raise ArgumentError, "When assigning attributes, you must pass a hash" \ " as an argument, #{.class} passed." end attributes.each do |attribute| # Try a `string` key if `symbol` key does not exist value = .delete(attribute.to_sym) value = .delete(attribute.to_s) if value.nil? send("#{attribute}=", value) unless value.nil? end @rest = end |
#params ⇒ Object
34 35 36 37 38 |
# File 'lib/composable/core/attribute_dsl.rb', line 34 def params attributes.each_with_object({}) do |attribute, hash| hash[attribute] = send(attribute) end end |
#rest ⇒ Object
40 41 42 |
# File 'lib/composable/core/attribute_dsl.rb', line 40 def rest @rest end |