Class: Rediline::Entry
- Inherits:
-
Object
- Object
- Rediline::Entry
- Defined in:
- lib/rediline/entry.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#queries ⇒ Object
readonly
Returns the value of attribute queries.
Instance Method Summary collapse
-
#initialize(content, queries = {}) ⇒ Entry
constructor
A new instance of Entry.
- #method_missing(name, *args) ⇒ Object
- #respond_to?(name, *args) ⇒ Boolean
- #to_json ⇒ Object
Constructor Details
#initialize(content, queries = {}) ⇒ Entry
Returns a new instance of Entry.
9 10 11 12 |
# File 'lib/rediline/entry.rb', line 9 def initialize(content, queries={}) @content, @queries = parse(content), queries @objects = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rediline/entry.rb', line 18 def method_missing(name, *args) return content[name] if content.include?(name) if content.include?(:"#{name}_object") && content.include?(:"#{name}_object") return @objects[name] ||= find_query(name, content[:"#{name}_id"]) end super end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/rediline/entry.rb', line 7 def content @content end |
#queries ⇒ Object (readonly)
Returns the value of attribute queries.
7 8 9 |
# File 'lib/rediline/entry.rb', line 7 def queries @queries end |
Instance Method Details
#respond_to?(name, *args) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/rediline/entry.rb', line 26 def respond_to?(name, *args) return true if content.include?(name.to_s) return true if content.include?("#{name}_object") && content.include?("#{name}_object") super end |
#to_json ⇒ Object
14 15 16 |
# File 'lib/rediline/entry.rb', line 14 def to_json @content.to_json end |