Class: Glimmer::DataBinding::Shine

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

Constant Summary

Constants included from Glimmer

GUI

Instance Method Summary collapse

Methods included from Glimmer

included

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

Instance Method Details

#<=(other) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/glimmer/data_binding/shine.rb', line 44

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 # || other.is_a?(Hash) # TODO support hash e.g. {model: model_obj, attribute: :some_attribute, more-options...}
      args_clone << {read_only: true}
    end
    @parent.content {
      send(@parent_attribute, bind(*args_clone))
    }
  end
end

#<=>(other) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/glimmer/data_binding/shine.rb', line 34

def <=>(other)
  if other.is_a?(Array)
    @parent.content {
      send(@parent_attribute, bind(*other))
    }
  else  # || other.is_a?(Hash) # TODO support hash e.g. {model: model_obj, attribute: :some_attribute, more-options...}
    original_compare(other)
  end
end

#original_compareObject



32
# File 'lib/glimmer/data_binding/shine.rb', line 32

alias original_compare <=>