module RedisModelExtension::Attributes
Attribues¶ ↑
modul for easier getting all attributes also for setting ang getting value instance variable
Public Instance Methods
to_arg()
click to toggle source
take all arguments and send them out
# File lib/redis-model-extension/attributes.rb, line 9 def to_arg redis_fields_config.inject({}) do |args, (key, type)| args[key] = self.send(key) args end end
Also aliased as: args
to_json()
click to toggle source
put arguments into json
# File lib/redis-model-extension/attributes.rb, line 19 def to_json to_arg.to_json end
Private Instance Methods
attribute?(name)
click to toggle source
# File lib/redis-model-extension/attributes.rb, line 37 def attribute?(name) value_get(name) && !value_get(name).blank? ? true : false end
value_get(name)
click to toggle source
get value from instance variable
# File lib/redis-model-extension/attributes.rb, line 26 def value_get name instance_variable_get(:"@#{name}") end
Also aliased as: attribute
value_set(name, value)
click to toggle source
set value into instance variable
# File lib/redis-model-extension/attributes.rb, line 32 def value_set name, value instance_variable_set(:"@#{name}", value_parse(value, redis_fields_defaults_config[name])) end
Also aliased as: attribute=