Module: RandomAttributes::ClassMethods

Defined in:
lib/random_attributes.rb

Instance Method Summary collapse

Instance Method Details

#after_parse(*args, &block) ⇒ Object



124
125
126
# File 'lib/random_attributes.rb', line 124

def after_parse(*args, &block)
  set_callback(:parse, :after, *args, &block)
end

#attribute(attrs, options = {}) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/random_attributes.rb', line 98

def attribute(attrs, options = {})
  register = Register.new attrs, options

  attribute_register[register.aliased] = register

  define_method register.aliased do
    get_attribute register
  end

  define_method :"#{register.aliased}=" do |value|
    set_attribute register.aliased, value
  end
end

#attribute_registerObject



112
113
114
# File 'lib/random_attributes.rb', line 112

def attribute_register
  @_attribute_register ||= {}
end

#before_parse(*args, &block) ⇒ Object



120
121
122
# File 'lib/random_attributes.rb', line 120

def before_parse(*args, &block)
  set_callback(:parse, :before, *args, &block)
end

#parse(attributes) ⇒ Object



116
117
118
# File 'lib/random_attributes.rb', line 116

def parse(attributes)
  new.parse attributes
end