Class: RMQViewData

Inherits:
Object show all
Defined in:
lib/project/ruby_motion_query/rmq_view_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#builtObject

, :cache_queries



2
3
4
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 2

def built
  @built
end

#cached_rmqObject

, :cache_queries



2
3
4
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 2

def cached_rmq
  @cached_rmq
end

#eventsObject

, :cache_queries



2
3
4
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 2

def events
  @events
end

#is_screen_root_viewObject

, :cache_queries



2
3
4
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 2

def is_screen_root_view
  @is_screen_root_view
end

#screenObject

, :cache_queries



2
3
4
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 2

def screen
  @screen
end

Instance Method Details

#activityObject



34
35
36
37
38
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 34

def activity
  if @screen
    @screen.getActivity
  end
end

#cleanupObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 8

def cleanup
  clear_query_cache
  if @cached_rmq
    @cached_rmq.selectors = nil
    @cached_rmq.parent_rmq = nil
    @cached_rmq = nil
  end
  @events = nil
  @screen = nil
  @_tags = nil
  @_styles = nil
  @_validation_errors = nil
  @validation_errors = nil
  @is_screen_root_view = false
  @built = false
  nil
end

#clear_query_cacheObject



30
31
32
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 30

def clear_query_cache
  @query_cache = {}
end

#has_style?(name = nil) ⇒ Boolean

view.rmq_data.has_style?(:style_name_here)



108
109
110
111
112
113
114
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 108

def has_style?(name = nil)
  if name
    self.styles.include?(name)
  else
    RMQ.is_blank?(@_styles)
  end
end

#has_tag?(tag_name = nil) ⇒ Boolean

Check if this view contains a specific tag



84
85
86
87
88
89
90
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 84

def has_tag?(tag_name = nil)
  if tag_name
    tags.include?(tag_name)
  else
    RMQ.is_blank?(@_tags)
  end
end

#query_cacheObject



26
27
28
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 26

def query_cache
  @_query_cache ||= {}
end

#screen_root_view?Boolean



4
5
6
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 4

def screen_root_view?
  !@is_screen_root_view.nil?
end

#style_nameObject



92
93
94
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 92

def style_name
  self.styles.first
end

#style_name=(value) ⇒ Object

Sets first style name, this is only here for backwards compatibility and as a convenience method



98
99
100
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 98

def style_name=(value)
  self.styles[0] = value
end

#stylesObject

view.rmq_data.styles



103
104
105
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 103

def styles
  @_styles ||= []
end

#tag(*tag_or_tags) ⇒ Object

*Do not* use this, use RMQ#tag instead:

Examples:

rmq(my_view).tag(:foo)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 53

def tag(*tag_or_tags)
  tag_or_tags.flatten!
  tag_or_tags = tag_or_tags.first if tag_or_tags.length == 1

  if tag_or_tags.is_a?(Array)
    tag_or_tags.each do |tag_name|
      tags[tag_name] = 1
    end
  elsif tag_or_tags.is_a?(Hash)
    tag_or_tags.each do |tag_name, tag_value|
      tags[tag_name] = tag_value
    end
  elsif tag_or_tags.is_a?(Symbol)
    tags[tag_or_tags] = 1
  end
end

#tag_namesArray



46
47
48
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 46

def tag_names
  tags.keys
end

#tagsHash



41
42
43
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 41

def tags
  @_tags ||= {}
end

#untag(*tag_or_tags) ⇒ Object

*Do not* use this, use RMQ#untag instead: Do nothing if no tag supplied or tag not present

Examples:

rmq(my_view).untag(:foo, :bar)


74
75
76
77
78
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 74

def untag(*tag_or_tags)
  tag_or_tags.flatten.each do |tag_name|
    tags.delete tag_name
  end
end

#validation_errorsObject



116
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 116

def validation_errors; @_validation_errors ||= {}; end

#validation_errors=(value) ⇒ Object



117
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 117

def validation_errors=(value); @_validation_errors = value; end

#validationsObject



118
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 118

def validations; @_validations ||= []; end

#validations=(value) ⇒ Object



119
# File 'lib/project/ruby_motion_query/rmq_view_data.rb', line 119

def validations=(value); @_validations = value; end