lib/amber_component/base.rb in amber_component-1.1.1 vs lib/amber_component/base.rb in amber_component-1.2.0

- old
+ new

@@ -40,13 +40,11 @@ # for defining callback such as `after_initialize` extend ::ActiveModel::Callbacks extend Helpers::ClassHelper include Helpers::CssHelper - include Views::InstanceMethods extend Views::ClassMethods - include Assets::InstanceMethods extend Assets::ClassMethods include Rendering::InstanceMethods extend Rendering::ClassMethods include Props::InstanceMethods extend Props::ClassMethods @@ -55,22 +53,44 @@ include ::Memery memoize :asset_dir_path # Memoize these methods in production - if ::ENV['RAILS_ENV'] == 'production' + if defined?(::Rails.env) && ::Rails.env.production? memoize :view_path memoize :view_file_name memoize :view_type end + # @return [Class] + def compiled_method_container + self + end + + # @return [String] + def type + 'text/html' + end + + # @return [Symbol] + def format + :html + end + + # @return [String] + def identifier + source_location.first + end + private # @param subclass [Class] # @return [void] def inherited(subclass) super + return unless subclass.name + method_body = lambda do |**kwargs, &block| subclass.render(**kwargs, &block) end parent_module = subclass.module_parent @@ -126,9 +146,14 @@ run_callbacks :initialize do next if bind_props(kwargs) bind_instance_variables(kwargs) end + end + + # @return [Class] + def compiled_method_container + self.class end private # @param kwargs [Hash{Symbol => Object}]