Module: Storext::InstanceMethods

Defined in:
lib/storext/instance_methods.rb

Instance Method Summary collapse

Instance Method Details

#_dump(level) ⇒ Object



33
34
35
# File 'lib/storext/instance_methods.rb', line 33

def _dump(level)
  self.to_yaml
end

#destroy_key(column, attr) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/storext/instance_methods.rb', line 4

def destroy_key(column, attr)
  new_value = send(column)
  if Rails.gem_version < Gem::Version.new("4.2.0")
    new_value = send(column).dup
  end
  new_value.delete(attr.to_s)
  storext_cast_proxy.reset_attribute(attr)

  send("#{column}=", new_value)
end

#destroy_keys(column, *attrs) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/storext/instance_methods.rb', line 15

def destroy_keys(column, *attrs)
  new_value = send(column)
  if Rails.gem_version < Gem::Version.new("4.2.0")
    new_value = send(column).dup
  end

  attrs.each do |a|
    new_value.delete(a.to_s)
    storext_cast_proxy.reset_attribute(a)
  end

  send("#{column}=", new_value)
end

#storext_has_key?(column, key) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/storext/instance_methods.rb', line 29

def storext_has_key?(column, key)
  send(column).with_indifferent_access.has_key?(key)
end