Module: FanartTv::BaseModel::ClassMethods

Defined in:
lib/fanart_tv/models/base_model.rb

Instance Method Summary collapse

Instance Method Details

#field(name, type) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/fanart_tv/models/base_model.rb', line 9

def field(name, type)
  self.class_exec do
    attr_reader name

    define_method("#{name}=") do |val|
      instance_variable_set("@#{name}", validate_type(val, type))
    end
  end
end