Module: Kashmir::Representable::ClassMethods
- Defined in:
- lib/kashmir/representable.rb
Instance Method Summary collapse
- #base(fields) ⇒ Object
- #definitions ⇒ Object
- #rep(field, options = {}) ⇒ Object
- #representations(&definitions) ⇒ Object
Instance Method Details
#base(fields) ⇒ Object
72 73 74 75 76 |
# File 'lib/kashmir/representable.rb', line 72 def base(fields) fields.each do |field| rep(field, { is_base: true }) end end |
#definitions ⇒ Object
83 84 85 |
# File 'lib/kashmir/representable.rb', line 83 def definitions @definitions ||= {} end |
#rep(field, options = {}) ⇒ Object
78 79 80 81 |
# File 'lib/kashmir/representable.rb', line 78 def rep(field, ={}) representation = Representation.new(field, ) definitions[field] = representation end |
#representations(&definitions) ⇒ Object
67 68 69 70 |
# File 'lib/kashmir/representable.rb', line 67 def representations(&definitions) @definitions = {} class_eval(&definitions) end |