Module: Cot::FrameClassMethods

Included in:
Frame
Defined in:
lib/cot/frame_class_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attr_methodsObject

Returns the value of attribute attr_methods.



3
4
5
# File 'lib/cot/frame_class_methods.rb', line 3

def attr_methods
  @attr_methods
end

#inverted_mappingsObject

Returns the value of attribute inverted_mappings.



3
4
5
# File 'lib/cot/frame_class_methods.rb', line 3

def inverted_mappings
  @inverted_mappings
end

#inverted_search_mappingsObject

Returns the value of attribute inverted_search_mappings.



3
4
5
# File 'lib/cot/frame_class_methods.rb', line 3

def inverted_search_mappings
  @inverted_search_mappings
end

#mappingsObject

Returns the value of attribute mappings.



3
4
5
# File 'lib/cot/frame_class_methods.rb', line 3

def mappings
  @mappings
end

#search_mappingsObject

Returns the value of attribute search_mappings.



3
4
5
# File 'lib/cot/frame_class_methods.rb', line 3

def search_mappings
  @search_mappings
end

#value_blocksObject

Returns the value of attribute value_blocks.



3
4
5
# File 'lib/cot/frame_class_methods.rb', line 3

def value_blocks
  @value_blocks
end

Instance Method Details

#enum(name, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/cot/frame_class_methods.rb', line 17

def enum(name, &block)
  obj = Enum.new
  obj.instance_eval(&block)
  define_singleton_method name do
    obj
  end
  define_method name do
    obj
  end
end

#property(name, args = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cot/frame_class_methods.rb', line 28

def property(name, args = {}, &block)
  set_default_values
  prop = Property.new args
  prop.instance_eval(&block) if block

  @value_blocks[name] = prop.value if prop.value

  key = prop.from
  @mappings[key.to_sym] = name if key
  @search_mappings[name] = key ? key : name if prop.searchable
  attr_methods << name.to_sym

  define_property_methods name
end

#search_property(name, args = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/cot/frame_class_methods.rb', line 10

def search_property(name, args = {})
  @search_mappings ||= {}

  key = args[:from] ? args[:from] : name
  @search_mappings[name] = key
end