Class: Freemium::FeatureSet

Inherits:
Object
  • Object
show all
Defined in:
lib/freemium/feature_set.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ FeatureSet

Returns a new instance of FeatureSet.



4
5
6
7
8
9
# File 'lib/freemium/feature_set.rb', line 4

def initialize(hash = {})
  hash.each do |key, value|
    self.class.class_eval { attr_accessor key.intern }
    self.send("#{key}=", value)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/freemium/feature_set.rb', line 11

def method_missing(method, *args, &block)
  # forward named routes
  if method.to_s.include? '?'
    send(method.to_s[0..-2], *args, &block)
  else
    super
  end
end

Class Method Details

.find(id) ⇒ Object



20
21
22
# File 'lib/freemium/feature_set.rb', line 20

def self.find(id)
  self.feature_sets[id.to_s]
end