Module: ActiveRecord::HstoreProperties::ClassMethods

Defined in:
lib/active_record/hstore_properties.rb

Instance Method Summary collapse

Instance Method Details

#default_property_klassObject



41
42
43
# File 'lib/active_record/hstore_properties.rb', line 41

def default_property_klass
  ActiveRecord::Properties::StringProperty
end

#properties(*args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/active_record/hstore_properties.rb', line 30

def properties(*args)
  if args.blank?
    self._properties ||= []
  else
    self._properties ||= []
    new_properties = extract_properties(args)
    self._properties += new_properties
    define_accessors_for(new_properties)
  end
end

#properties_set(*args) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/active_record/hstore_properties.rb', line 21

def properties_set(*args)
  self._properties.dup.tap do |all_properties|
    unless args.blank?
      all_properties.select! { |property| args.include?(property.name) }
    end
    all_properties.reject! { |property| property.name.to_s.starts_with?('_') }
  end
end