Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/facebooker/rails/helpers.rb
Constant Summary collapse
- FB_ALWAYS_VALID_OPTION_KEYS =
We can allow css attributes.
[:class, :style]
Instance Method Summary collapse
- #assert_valid_keys(*valid_keys) ⇒ Object
-
#swapkey!(newkey, oldkey) ⇒ Object
This method is lifted from Ruby Facets core.
- #transform_key!(old_key, new_key) ⇒ Object
- #transform_keys!(transformation_hash) ⇒ Object
Instance Method Details
#assert_valid_keys(*valid_keys) ⇒ Object
758 759 760 761 |
# File 'lib/facebooker/rails/helpers.rb', line 758 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 |
#swapkey!(newkey, oldkey) ⇒ Object
This method is lifted from Ruby Facets core
751 752 753 754 |
# File 'lib/facebooker/rails/helpers.rb', line 751 def swapkey!( newkey, oldkey ) self[newkey] = self.delete(oldkey) if self.has_key?(oldkey) self end |
#transform_key!(old_key, new_key) ⇒ Object
746 747 748 |
# File 'lib/facebooker/rails/helpers.rb', line 746 def transform_key!(old_key, new_key) swapkey!(new_key, old_key) end |
#transform_keys!(transformation_hash) ⇒ Object
741 742 743 |
# File 'lib/facebooker/rails/helpers.rb', line 741 def transform_keys!(transformation_hash) transformation_hash.each_pair{|key, value| transform_key!(key, value)} end |