Class: Soy::Page
- Inherits:
-
Object
- Object
- Soy::Page
- Defined in:
- lib/soy/page.rb
Overview
Container of data for a given page
Instance Method Summary collapse
- #method_missing(_) ⇒ Object
- #respond_to_missing? ⇒ Boolean
-
#set(args) ⇒ Object
Create reader and writers for the passed in hash keys.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(_) ⇒ Object
23 24 25 |
# File 'lib/soy/page.rb', line 23 def method_missing(_) nil end |
Instance Method Details
#respond_to_missing? ⇒ Boolean
27 28 29 |
# File 'lib/soy/page.rb', line 27 def respond_to_missing? true end |
#set(args) ⇒ Object
Create reader and writers for the passed in hash keys
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/soy/page.rb', line 7 def set(args) raise ArgumentError, "must set with a Hash" unless args.is_a?(Hash) args.each do |attr, attr_val| self.class.send(:define_method, "#{attr}=".to_sym) do |value| instance_variable_set("@#{attr}", value) end self.class.send(:define_method, attr.to_sym) do instance_variable_get("@#{attr}") end public_send("#{attr}=".to_sym, attr_val) end end |