Class: Glimmer::DataBinding::Shine

Inherits:
Object
  • Object
show all
Includes:
Glimmer
Defined in:
lib/glimmer/data_binding/shine.rb

Instance Method Summary collapse

Methods included from Glimmer

loop, loop_increment!, loop_reset!, #method_missing

Constructor Details

#initialize(parent, parent_attribute) ⇒ Shine

Returns a new instance of Shine.



27
28
29
30
# File 'lib/glimmer/data_binding/shine.rb', line 27

def initialize(parent, parent_attribute)
  @parent = parent
  @parent_attribute = parent_attribute
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer

Instance Method Details

#<=(other) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/glimmer/data_binding/shine.rb', line 41

def <=(other)
  if other.is_a?(Array)
    args_clone = other.clone
    if args_clone.last.is_a?(Hash)
      args_clone.last[:read_only] = true
    else
      args_clone << {read_only: true}
    end
    @parent.content {
      send(@parent_attribute, bind(*args_clone))
    }
  end
end

#<=>(other) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/glimmer/data_binding/shine.rb', line 32

def <=>(other)
  if other.is_a?(Array)
    args_clone = other.clone
    @parent.content {
      send(@parent_attribute, bind(*args_clone))
    }
  end
end