Class: Undies::Source
- Inherits:
-
Object
- Object
- Undies::Source
- Defined in:
- lib/undies/source.rb,
lib/undies/named_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.
8 9 10 11 12 |
# File 'lib/undies/source.rb', line 8 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.
6 7 8 |
# File 'lib/undies/source.rb', line 6 def data @data end |
#layout ⇒ Object
Returns the value of attribute layout.
6 7 8 |
# File 'lib/undies/source.rb', line 6 def layout @layout end |
#source ⇒ Object
Returns the value of attribute source.
6 7 8 |
# File 'lib/undies/source.rb', line 6 def source @source end |
Instance Method Details
#==(other_source) ⇒ Object
30 31 32 33 |
# File 'lib/undies/source.rb', line 30 def ==(other_source) self.source == other_source.source && self.layout_sources == other_source.layout_sources end |
#args=(values) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/undies/source.rb', line 35 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
14 15 16 |
# File 'lib/undies/source.rb', line 14 def file? !@source.kind_of?(::Proc) end |
#layout_sources ⇒ Object
26 27 28 |
# File 'lib/undies/source.rb', line 26 def layout_sources self.layouts.collect{|l| l.source} end |
#layouts ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/undies/source.rb', line 18 def layouts if layout [self.layout, self.layout.layouts].flatten.compact else [] end end |