Sha256: 015467ba61b73c159b24f4cdf22037a3b72938b8255667f18ff14431f89e6615
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module OptionsModel class Base include ActiveModel::Model include OptionsModel::Concerns::Serialization include OptionsModel::Concerns::Attributes include OptionsModel::Concerns::AttributeAssignment validate do self.class.attribute_names.each do |attribute_name| attribute = public_send(attribute_name) if attribute.is_a?(self.class) && attribute.invalid? errors.add attribute_name, :invalid end end end def ==(other) other.instance_of?(self.class) && attributes == other.attributes && nested_attributes == other.nested_attributes && unused_attributes == other.unused_attributes end alias :eql? :== def hash [attributes, nested_attributes, unused_attributes].hash end def inspect "#<#{self.class.name}:OptionsModel #{self.to_h}>" end def self.inspect "#<#{name}:OptionsModel [#{attribute_names.map(&:inspect).join(', ')}]>" end def persisted? true end def self.derive(name) Class.new(self) do include OptionsModel::Concerns::NameHacking self.name = name end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
options_model-0.0.5 | lib/options_model/base.rb |
options_model-0.0.4 | lib/options_model/base.rb |