Sha256: 5905173fc980b8d27f4ca4c2f41fd035a89e4b51ba5036a501f5bbad583598c7
Contents?: true
Size: 755 Bytes
Versions: 1
Compression:
Stored size: 755 Bytes
Contents
module LazyModelSupport extend ActiveSupport::Concern included do attr_accessor :raw_attribute, :enumerables, :custom_finders, :column, :model, :attribute, :belongs_to end def initialize(model, raw_attribute, enumerables = nil, custom_finders = {}) self.model = model self.raw_attribute = raw_attribute self.enumerables = enumerables self.custom_finders = custom_finders calculate_atttribute_and_belongs_to end def to_method_name(any_string_or_symbol) any_string_or_symbol.to_s.underscore end private def calculate_atttribute_and_belongs_to if raw_attribute.is_a?(Hash) self.belongs_to = raw_attribute.keys.first self.attribute = raw_attribute[attribute] else self.attribute = raw_attribute end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lazy_model-0.0.8 | lib/lazy_model/lazy_model_support.rb |