module Ahora::Representation::Definition
Public Instance Methods
attribute(*names)
click to toggle source
# File lib/ahora/representation.rb, line 28 def attribute(*names) names = names.flatten parser = names.pop if names.last.is_a?(Proc) names.each do |name| if Hash === name selector, name = name.first else selector = attribute_selector(name) end element selector => name.to_s, :with => parser end end
attribute_selector(name)
click to toggle source
override in subclasses for e.g. camelCase support
# File lib/ahora/representation.rb, line 42 def attribute_selector(name) name.to_s end
boolean(*names)
click to toggle source
# File lib/ahora/representation.rb, line 67 def boolean(*names) attribute(names, BOOL_PARSER) end
date(*names)
click to toggle source
# File lib/ahora/representation.rb, line 58 def date(*names) attribute(names, DATE_PARSER) end
element(*)
click to toggle source
Calls superclass method
# File lib/ahora/representation.rb, line 20 def element(*) name = super define_method "#{name}?" do !!instance_variable_get("@#{name}") end name end
float(*names)
click to toggle source
# File lib/ahora/representation.rb, line 54 def float(*names) attribute(names, FLOAT_PARSER) end
integer(*names)
click to toggle source
# File lib/ahora/representation.rb, line 50 def integer(*names) attribute(names, INTEGER_PARSER) end
string(*names)
click to toggle source
# File lib/ahora/representation.rb, line 46 def string(*names) attribute(names, STRING_PARSER) end
time(*names)
click to toggle source
FIXME test
# File lib/ahora/representation.rb, line 63 def time(*names) attribute(names, TIME_PARSER) end
Private Instance Methods
base_parser_class()
click to toggle source
allows using block sub-parsers without explicitly stating they need to inherit from Ahora::Representation
# File lib/ahora/representation.rb, line 75 def base_parser_class Representation end