Class: Marley::ReggaeInstance

Inherits:
ReggaeResource show all
Defined in:
lib/marley/reggae.rb

Instance Attribute Summary collapse

Attributes inherited from Reggae

#contents, #properties, #resource_type

Instance Method Summary collapse

Methods inherited from ReggaeResource

#update

Methods inherited from Reggae

#find_instances, get_resource, #is_resource?, mk_prop_methods, properties, #to_resource

Constructor Details

#initialize(*args) ⇒ ReggaeInstance

Returns a new instance of ReggaeInstance.



88
89
90
91
92
# File 'lib/marley/reggae.rb', line 88

def initialize(*args)
  super
  @properties[:schema]=ReggaeSchema.new(self.schema)
  @schema=@properties[:schema]
end

Instance Attribute Details

#schemaObject

Returns the value of attribute schema.



87
88
89
# File 'lib/marley/reggae.rb', line 87

def schema
  @schema
end

Instance Method Details

#col_value(col_name, col_value = nil) ⇒ Object



99
100
101
102
103
# File 'lib/marley/reggae.rb', line 99

def col_value(col_name,col_value=nil)
  col=@schema[col_name]
  col.col_value=col_value if col_value
  col.col_value
end

#set_values(col_hash) ⇒ Object



104
105
106
107
# File 'lib/marley/reggae.rb', line 104

def set_values(col_hash)
  col_hash.each_pair {|k,v| col_value(k,v)}
  self
end

#to_paramsObject



93
94
95
96
97
98
# File 'lib/marley/reggae.rb', line 93

def to_params
  @schema.inject({}) do |params,spec| 
    params["#{name}[#{spec.col_name}]"]=spec.col_value unless (spec.col_restrictions & RESTRICT_RO > 0)
    params
  end
end