Class: RailsJqGrid::JqGridOptionOrMethod

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Inflector
Defined in:
app/models/rails_jq_grid/jq_grid_option_or_method.rb

Overview

Contains all information for one option or method

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value = nil) ⇒ JqGridOptionOrMethod

Returns a new instance of JqGridOptionOrMethod.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 19

def initialize(name, value=nil)
  self.name = name

  if (value.is_a?(Hash))
    self.type = value[:type]
    self.value = value[:value]
  else
    self.type = :json
    self.value = value
  end

end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



17
18
19
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 17

def name
  @name
end

#typeObject

Returns the value of attribute type.



17
18
19
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 17

def type
  @type
end

#valueObject

Returns the value of attribute value.



17
18
19
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 17

def value
  @value
end

Instance Method Details

#<<(*args) ⇒ Object

works like JqGridMethodMissing.raw



33
34
35
36
37
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 33

def <<(*args)
  RAILS_DEFAULT_LOGGER.debug "#{args.inspect}"
  self.type = :raw
  self.value = args[0]
end

#escaped_nameObject

option name ist camalized with a lower start character transforms from ruby style to jqgrid style before_submit => beforeSubmit



42
43
44
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 42

def escaped_name
  self.name.to_s.camelize(:lower)
end

#escaped_valueObject

every value is transformed to json as lang es it isn’t marked es raw



48
49
50
51
52
53
54
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 48

def escaped_value
  if self.type == :raw
    self.value
  else
    self.value.to_json
  end
end

#to_sObject



56
57
58
# File 'app/models/rails_jq_grid/jq_grid_option_or_method.rb', line 56

def to_s
  self.escaped_value
end