Class: Jasonette::Action

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

Direct Known Subclasses

Jason::Head::Actions

Constant Summary

Constants included from Properties

Properties::DEFAULT_IS_ARRAY, Properties::TYPES

Instance Attribute Summary

Attributes inherited from Base

#attributes, #context

Instance Method Summary collapse

Methods inherited from Base

#_method, #array!, #as_json, #attr_value, #attributes!, #empty?, #encode, #extract!, #implicit_set!, #initialize, #inline, #klass, #merge!, #method_missing, #set!, #with_attributes

Methods included from Properties

#all_instance_variable_set, #create_new_klass, #get_default_for_property, #get_ivar, #has_any_property_type?, #has_property?, included, #ivar_for_property, #klass_for_property, #merge_properties, #parent_jasonette, #parent_jasonette_set, #prop, #properties_empty?, #property_get!, #property_names, #property_sender, #property_set!, #property_variables, #set_ivar

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

#error(&block) ⇒ Object



29
30
31
32
# File 'lib/jasonette/core/action.rb', line 29

def error &block
  @error = Jasonette::Action.new(context, &block)
  self
end

#reload!Object



18
19
20
# File 'lib/jasonette/core/action.rb', line 18

def reload!
  set! "type", "$reload"
end

#render!Object



14
15
16
# File 'lib/jasonette/core/action.rb', line 14

def render!
  set! "type", "$render"
end

#success(&block) ⇒ Object



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

def success &block
  @success = Jasonette::Action.new(context) do
    block_given? ? encode(&block) : render!
  end
  self
end

#trigger(name, &block) ⇒ Object



7
8
9
10
11
12
# File 'lib/jasonette/core/action.rb', line 7

def trigger name, &block
  with_attributes do
    set! "trigger", name
    encode(&block) if block_given?
  end
end