Class: Marbu::Models::Code

Inherits:
Object
  • Object
show all
Defined in:
lib/marbu/models/mrf/code.rb

Constant Summary collapse

JS =
"JS"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ext_params = {}) ⇒ Code

Returns a new instance of Code.



8
9
10
11
12
# File 'lib/marbu/models/mrf/code.rb', line 8

def initialize( ext_params = {} )
  params              = default_params.merge( ext_params.keep_if{|k,v|v} )
  @text               = params[:text]
  @type               = params[:type]
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



4
5
6
# File 'lib/marbu/models/mrf/code.rb', line 4

def text
  @text
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/marbu/models/mrf/code.rb', line 4

def type
  @type
end

Instance Method Details

#default_paramsObject



14
15
16
17
18
# File 'lib/marbu/models/mrf/code.rb', line 14

def default_params
  {
    :type       => JS
  }
end

#present?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/marbu/models/mrf/code.rb', line 27

def present?
  text.present?
end

#serializable_hashObject



20
21
22
23
24
25
# File 'lib/marbu/models/mrf/code.rb', line 20

def serializable_hash
  {
    :text       => text,
    :type       => type
  }.delete_if{|k,v|v.blank?}
end