Module: Hashme::Properties::ClassMethods

Defined in:
lib/hashme/properties.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#propertiesObject

Returns the value of attribute properties.



37
38
39
# File 'lib/hashme/properties.rb', line 37

def properties
  @properties
end

Instance Method Details

#property(*args) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/hashme/properties.rb', line 39

def property(*args)
  self.properties ||= {}

  # Prepare the property object and methods
  property = Property.new(*args)
  properties[property.name] = property
  define_property_methods(property)

  property
end

#search_property(name) ⇒ Object

Recursive search the property in the superclass chain



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/hashme/properties.rb', line 51

def search_property(name)        
  name = name.to_sym
  
  if properties[name]
    properties[name]
  elsif superclass.respond_to?(:search_property)
    superclass.search_property(name)
  else
    nil
  end
end