class RKit::Grid::Binding::Attributes
Attributes
attributes[RW]
Public Class Methods
new()
click to toggle source
# File lib/r_kit/grid/binding.rb, line 46 def initialize @attributes = Hash.new{ |hash, key| hash[key] = Array.new } end
Public Instance Methods
attributes=(attributes)
click to toggle source
TODO: Allow to take only a proc (so not a hash) TODO: OR a single symbol (and we use that to send a method on the object) TODO: Tha last one can be replaced (or duplicated) by a “respond_to?” automatically triggered from here
# File lib/r_kit/grid/binding.rb, line 54 def attributes= attributes @attributes.merge!(attributes) do |key, old_value, new_value| Array.wrap(old_value) | Array.wrap(new_value) end end
process(value, object = nil)
click to toggle source
# File lib/r_kit/grid/binding.rb, line 69 def process value, object = nil case value when Proc process(value.call(object), object) when Array value.map{ |unique_value| process(unique_value, object) }.join(' ') when String, Symbol value.dasherize else raise ArgumentError, 'Must be Array, Proc or String/Symbol' end end