Class: RKit::Grid::Binding::Attributes
- Inherits:
-
Object
- Object
- RKit::Grid::Binding::Attributes
- Defined in:
- lib/r_kit/grid/binding.rb
Instance Attribute Summary collapse
-
#attributes(object = nil) ⇒ Object
TODO: @computed need to be back, we compute what can be, the procs or methods will be calc each time.
Instance Method Summary collapse
-
#initialize ⇒ Attributes
constructor
A new instance of Attributes.
- #process(value, object = nil) ⇒ Object
Constructor Details
#initialize ⇒ Attributes
Returns a new instance of Attributes.
49 50 51 |
# File 'lib/r_kit/grid/binding.rb', line 49 def initialize @attributes = Hash.new{ |hash, key| hash[key] = Array.new } end |
Instance Attribute Details
#attributes(object = nil) ⇒ Object
TODO: @computed need to be back, we compute what can be, the procs or methods will be calc each time
64 65 66 |
# File 'lib/r_kit/grid/binding.rb', line 64 def attributes @attributes end |
Instance Method Details
#process(value, object = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/r_kit/grid/binding.rb', line 72 def process value, object = nil case value when Proc proc_value = case value.arity when 1 then value.call(object) else value.call end process(proc_value, object) when Array value.map{ |unique_value| process(unique_value, object) }.join(' ') when String, Symbol value.to_s.dasherize else raise ArgumentError, 'Must be Array, Proc or String/Symbol' end end |