Class: Yify::Models::Base

Inherits:
Object
  • Object
show all
Includes:
Support::Utils
Defined in:
lib/yify/models/base.rb

Instance Method Summary collapse

Methods included from Support::Utils

#map_class, #post_params, #symbolize_keys

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/yify/models/base.rb', line 9

def initialize(params)
  self.extend(Virtus.model)

  params.each do |key, value|
    klass = map_class(key)

    begin Yify::Models.const_get klass.to_s.classify
      attribute key, Array[Yify::Models.const_get klass.to_s.classify]
    rescue
      attribute key, value.class
    end

    self[key] = value
  end
end