Module: Muffin::Attributes

Included in:
Base, NestedAttribute
Defined in:
lib/muffin/frostings/attributes.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

Boolean =
Muffin::Boolean.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



45
46
47
# File 'lib/muffin/frostings/attributes.rb', line 45

def attributes
  @attributes
end

Class Method Details

.included(base) ⇒ Object



57
58
59
# File 'lib/muffin/frostings/attributes.rb', line 57

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#assign_attributesObject



53
54
55
# File 'lib/muffin/frostings/attributes.rb', line 53

def assign_attributes
  self.attributes = params
end

#persisted?Boolean

Returns:



61
62
63
# File 'lib/muffin/frostings/attributes.rb', line 61

def persisted?
  attributes[:id].present?
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

fields_for checks wether an object responds to [foo_attributes=]

Returns:



66
67
68
69
# File 'lib/muffin/frostings/attributes.rb', line 66

def respond_to_missing?(method_name, include_private = false)
  return true if method_name.to_s[/_attributes=\Z/]
  super
end