module Quiver::Patcher::ClassMethods
Public Class Methods
build_validation_class(&block)
click to toggle source
# File lib/quiver/patcher.rb, line 22 def self.build_validation_class(&block) kls = Class.new(self) kls.class_eval(&block) kls end
new(attributes)
click to toggle source
Calls superclass method
# File lib/quiver/patcher.rb, line 28 def initialize(attributes) @raw_attributes = attributes super end
param(name, options={}, &block)
click to toggle source
# File lib/quiver/patcher.rb, line 17 def self.param(name, options={}, &block) attribute(name, options, &block) nil end
Public Instance Methods
[](key)
click to toggle source
# File lib/quiver/patcher.rb, line 33 def [](key) @attributes.get(key) end
get_params_attributes_klass()
click to toggle source
# File lib/quiver/patcher.rb, line 48 def get_params_attributes_klass instance_variable_get('@params_attributes') end
params(&block)
click to toggle source
# File lib/quiver/patcher.rb, line 13 def params(&block) klass = Class.new do include Lotus::Validations def self.param(name, options={}, &block) attribute(name, options, &block) nil end def self.build_validation_class(&block) kls = Class.new(self) kls.class_eval(&block) kls end def initialize(attributes) @raw_attributes = attributes super end def [](key) @attributes.get(key) end def to_h super.select do |key, _| @raw_attributes.to_h.has_key?(key.to_s) || @raw_attributes.to_h.has_key?(key.to_sym) end end end klass.instance_exec(&block) instance_variable_set('@params_attributes', klass) end
to_h()
click to toggle source
Calls superclass method
# File lib/quiver/patcher.rb, line 37 def to_h super.select do |key, _| @raw_attributes.to_h.has_key?(key.to_s) || @raw_attributes.to_h.has_key?(key.to_sym) end end
values(&block)
click to toggle source
# File lib/quiver/patcher.rb, line 9 def values(&block) warn '`values` is no longer supported.' end