Module: TMDBParty::Attributes::ClassMethods
- Defined in:
- lib/tmdb_party/attributes.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tmdb_party/attributes.rb', line 22 def attribute(name, ) .replace({:type => 'nil', :lazy=>false}.merge()) raise "Name can't be empty" if name.blank? lazy_load = "self.#{[:lazy]} unless self.loaded?" if [:lazy] class_eval <<-EOS def #{name} #{lazy_load} @#{name} ||= decode_raw_attribute(@attributes['#{name}'], #{[:type]}) if @attributes end EOS end |
#attributes(*names) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/tmdb_party/attributes.rb', line 14 def attributes(*names) = names. names.each do |name| attribute name, unless name.blank? end end |