Module: Sheety::Children

Included in:
Api, Feed
Defined in:
lib/sheety/children.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
# File 'lib/sheety/children.rb', line 2

def self.included base
  base.extend ClassMethods
end

Instance Method Details

#_get_i_val(item, c_key, accessor = nil) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/sheety/children.rb', line 21

def _get_i_val(item, c_key, accessor=nil)
  if accessor && item.respond_to?(accessor)
    return item.send(accessor, c_key)
  else
    return item.try(c_key)
  end
end

#_passes_constraint(i_val, c_val) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sheety/children.rb', line 6

def _passes_constraint(i_val, c_val)
  case c_val # Good Read: http://ruby.about.com/od/beginningruby/qt/On-Case-And-Class.htm
    when Range
      c_val.include? i_val
    when Array
      c_val.include? i_val
    when Regexp
      c_val =~ i_val
    when String
      c_val == i_val.to_s
    else
      c_val == i_val
  end
end