Class: Marbu::Models::KeyValueBase
- Inherits:
-
Object
- Object
- Marbu::Models::KeyValueBase
- Defined in:
- lib/marbu/models/mrf/base.rb
Instance Attribute Summary collapse
-
#function ⇒ Object
Returns the value of attribute function.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(params) ⇒ KeyValueBase
constructor
A new instance of KeyValueBase.
- #present? ⇒ Boolean
- #serializable_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params) ⇒ KeyValueBase
Returns a new instance of KeyValueBase.
71 72 73 74 75 76 77 78 |
# File 'lib/marbu/models/mrf/base.rb', line 71 def initialize(params) #params.keys.each do |k| # send("#{k}=".to_sym, params[k]) if respond_to?(k) #end self.name = params[:name] self.function = params[:function] end |
Instance Attribute Details
#function ⇒ Object
Returns the value of attribute function.
69 70 71 |
# File 'lib/marbu/models/mrf/base.rb', line 69 def function @function end |
#name ⇒ Object
Returns the value of attribute name.
69 70 71 |
# File 'lib/marbu/models/mrf/base.rb', line 69 def name @name end |
Instance Method Details
#blank? ⇒ Boolean
96 97 98 |
# File 'lib/marbu/models/mrf/base.rb', line 96 def blank? !present? end |
#present? ⇒ Boolean
92 93 94 |
# File 'lib/marbu/models/mrf/base.rb', line 92 def present? name.present? && function.present? end |
#serializable_hash ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/marbu/models/mrf/base.rb', line 84 def serializable_hash # don't return nil values in hash { :name => @name, :function => @function }.keep_if{|k,v| v} end |
#to_s ⇒ Object
100 101 102 |
# File 'lib/marbu/models/mrf/base.rb', line 100 def to_s name end |