Class: Undies::Source
- Inherits:
-
Object
- Object
- Undies::Source
- Defined in:
- lib/undies/source.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #==(other_source) ⇒ Object
- #args=(values) ⇒ Object
- #file? ⇒ Boolean
-
#initialize(*args, &block) ⇒ Source
constructor
A new instance of Source.
- #layout_sources ⇒ Object
- #layouts ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Source
Returns a new instance of Source.
7 8 9 10 11 |
# File 'lib/undies/source.rb', line 7 def initialize(*args, &block) named = args.first.kind_of?(NamedSource) ? args.first : nil args << block if block self.args = named ? named.args.compact : args end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/undies/source.rb', line 5 def data @data end |
#layout ⇒ Object
Returns the value of attribute layout.
5 6 7 |
# File 'lib/undies/source.rb', line 5 def layout @layout end |
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/undies/source.rb', line 5 def source @source end |
Instance Method Details
#==(other_source) ⇒ Object
29 30 31 32 |
# File 'lib/undies/source.rb', line 29 def ==(other_source) self.source == other_source.source && self.layout_sources == other_source.layout_sources end |
#args=(values) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/undies/source.rb', line 34 def args=(values) proc, opts, file = [ values.last.kind_of?(::Proc) ? values.pop : nil, values.last.kind_of?(::Hash) ? values.pop : {}, values.last.kind_of?(::String) ? values.pop : nil ] self.source = file || proc self.layout = opts[:layout] end |
#file? ⇒ Boolean
13 14 15 |
# File 'lib/undies/source.rb', line 13 def file? !@source.kind_of?(::Proc) end |
#layout_sources ⇒ Object
25 26 27 |
# File 'lib/undies/source.rb', line 25 def layout_sources self.layouts.collect{|l| l.source} end |
#layouts ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/undies/source.rb', line 17 def layouts if layout [self.layout, self.layout.layouts].flatten.compact else [] end end |