Class: Wedge::Config
Instance Attribute Summary collapse
-
#data ⇒ OpenStruct
Stores the options for the config.
Instance Method Summary collapse
- #client_data ⇒ Object
-
#initialize(opts = {}) ⇒ Config
constructor
Setup initial opts values.
- #method_missing(method, *args, &block) ⇒ Object
- #plugin(name) ⇒ Object
Methods included from Methods
Constructor Details
#initialize(opts = {}) ⇒ Config
Setup initial opts values
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wedge/config.rb', line 13 def initialize(opts = {}) @data = HashObject.new({ name: nil, path: nil, html: nil, scope: nil, debug: false, assets_url: '/assets/wedge', assets_key: false, cache_assets: false, is_plugin: false, requires: IndifferentHash.new, triggered_browser_events: false, store: IndifferentHash.new, settings: IndifferentHash.new, tmpl: IndifferentHash.new, on_block: [], on_compile: [], on_block_count: 0, server_methods: [], initialize_args: [], plugins: [], allowed_client_data: %w(name path method_args method_called store tmpl key cache_assets assets_key assets_url assets_url_with_host) }.merge(opts)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/wedge/config.rb', line 56 def method_missing(method, *args, &block) if @data.respond_to?(method, true) @data.send method, *args, &block else super end end |
Instance Attribute Details
#data ⇒ OpenStruct
Stores the options for the config
8 9 10 |
# File 'lib/wedge/config.rb', line 8 def data @data end |
Instance Method Details
#client_data ⇒ Object
39 40 41 |
# File 'lib/wedge/config.rb', line 39 def client_data @data.dup.select {|k, v| allowed_client_data.include? k } end |
#plugin(name) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/wedge/config.rb', line 43 def plugin(name) unless RUBY_ENGINE == 'opal' require "wedge/plugins/#{name}" end klass = Wedge.config.component_class[:"#{name}_plugin"] plugins << klass.config.path unless plugins.include? klass.config.path # Merge in instance/class methods Wedge::Component.include(klass::InstanceMethods) if defined?(klass::InstanceMethods) Wedge::Component.extend(klass::ClassMethods) if defined?(klass::ClassMethods) end |