Class: Daddy::Model

Inherits:
Hash
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
lib/daddy/model.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Model

Returns a new instance of Model.



9
10
11
# File 'lib/daddy/model.rb', line 9

def initialize(params = {})
  self.merge!(params) if params
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *params) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/daddy/model.rb', line 17

def method_missing(method, *params)
  method_name = method.to_s
  if method_name.last == "="
    self[method_name[0..-2]] = params.first
  else
    self[method_name]
  end
end

Instance Method Details

#persisted?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/daddy/model.rb', line 13

def persisted?
  false
end