Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/facebooker/rails/helpers.rb

Constant Summary

FB_ALWAYS_VALID_OPTION_KEYS =

We can allow css attributes.

[:class, :style]

Instance Method Summary (collapse)

Instance Method Details

- (Object) assert_valid_keys(*valid_keys)

Raises:

  • (ArgumentError)


831
832
833
834
# File 'lib/facebooker/rails/helpers.rb', line 831

def assert_valid_keys(*valid_keys)
  unknown_keys = keys - [valid_keys + FB_ALWAYS_VALID_OPTION_KEYS].flatten
  raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty?
end

- (Object) swapkey!(newkey, oldkey)

This method is lifted from Ruby Facets core



824
825
826
827
# File 'lib/facebooker/rails/helpers.rb', line 824

def swapkey!( newkey, oldkey )
  self[newkey] = self.delete(oldkey) if self.has_key?(oldkey)
  self
end

- (Object) transform_key!(old_key, new_key)



819
820
821
# File 'lib/facebooker/rails/helpers.rb', line 819

def transform_key!(old_key, new_key)
  swapkey!(new_key, old_key)
end

- (Object) transform_keys!(transformation_hash)



814
815
816
# File 'lib/facebooker/rails/helpers.rb', line 814

def transform_keys!(transformation_hash)
  transformation_hash.each_pair{|key, value| transform_key!(key, value)}
end