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