Class: GuardianSearcher::Content
- Inherits:
-
Object
- Object
- GuardianSearcher::Content
- Includes:
- Helpers::Util
- Defined in:
- lib/guardian_searcher/content.rb
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Content
constructor
A new instance of Content.
Methods included from Helpers::Util
Constructor Details
#initialize(attributes) ⇒ Content
Returns a new instance of Content.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/guardian_searcher/content.rb', line 6 def initialize(attributes) attributes.each do |key, attribute_value| attr_name = key attr_name = snakecase(key) unless key.is_a? Symbol self.class.send(:define_method, "#{attr_name}=".to_sym) do |value| instance_variable_set("@#{attr_name}", value) end self.class.send(:define_method, attr_name.to_sym) do instance_variable_get("@#{attr_name}") end send("#{attr_name}=".to_sym, attribute_value) end end |