Class: Jasonette::Items

Inherits:
Base
  • Object
show all
Defined in:
lib/jasonette/core/items.rb

Direct Known Subclasses

Components

Instance Attribute Summary

Attributes inherited from Base

#attributes, #context, #json

Instance Method Summary collapse

Methods inherited from Base

#action, #attr_value, #attributes!, #empty?, #encode, #implicit_set!, #initialize, #inline, #inline!, #klass, #method_missing, #reload!, #render!, #success, #target!, #trigger, #with_attributes

Methods included from Properties

included, #klass_for_property, #merge_properties, #prop, #properties, #properties_empty?, #property_get!, #property_sender, #property_set!

Constructor Details

This class inherits a constructor from Jasonette::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jasonette::Base

Instance Method Details

#image(uri = nil) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/jasonette/core/items.rb', line 13

def image uri=nil
  item = Jasonette::Base.new(@context) do
    type "image"
    url uri unless uri.nil?
    with_attributes { instance_eval(&::Proc.new) } if block_given?
  end
  append item
end

#label(caption = nil) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/jasonette/core/items.rb', line 4

def label caption=nil
  item = Jasonette::Base.new(@context) do
    text caption unless caption.nil?
    type "label"
    with_attributes { instance_eval(&::Proc.new) } if block_given?
  end
  append item
end

#layout(orientation = "vertical") ⇒ Object



22
23
24
25
26
27
28
# File 'lib/jasonette/core/items.rb', line 22

def layout orientation="vertical"
  item = Jasonette::Layout.new(@context) do
    type orientation
    with_attributes { instance_eval(&::Proc.new) } if block_given?
  end
  append item
end