Module: Kashmir::Representable::ClassMethods

Defined in:
lib/kashmir/representable.rb

Instance Method Summary collapse

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

#definitionsObject



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, options={})
  representation = Representation.new(field, options)
  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