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.



41
42
43
# File 'lib/muffin/frostings/attributes.rb', line 41

def attributes
  @attributes
end

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#assign_attributesObject



49
50
51
# File 'lib/muffin/frostings/attributes.rb', line 49

def assign_attributes
  self.attributes = params
end

#persisted?Boolean

Returns:



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

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:



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

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