Class: ActiveOopish::RSpecHelper::ValidationTarget

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/activeoopish/rspec_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ValidationTarget

Returns a new instance of ValidationTarget.



38
39
40
# File 'lib/activeoopish/rspec_helper.rb', line 38

def initialize(attributes = {})
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



52
53
54
55
56
57
58
59
# File 'lib/activeoopish/rspec_helper.rb', line 52

def method_missing(name, *args)
  if name.to_s.end_with?('=')
    name = remove_trailing_equal(name)
    @attributes[name] = args.first
  elsif @attributes.include?(name)
    read_attribute_for_validation(name)
  end
end

Instance Method Details

#read_attribute_for_validation(key) ⇒ Object



42
43
44
# File 'lib/activeoopish/rspec_helper.rb', line 42

def read_attribute_for_validation(key)
  @attributes[key.to_sym]
end